home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / trace / tcpdump-2.2.1 / savefile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-17  |  2.8 KB  |  76 lines

  1. /*
  2.  * Copyright (c) 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that: (1) source code distributions
  7.  * retain the above copyright notice and this paragraph in its entirety, (2)
  8.  * distributions including binary code include the above copyright notice and
  9.  * this paragraph in its entirety in the documentation or other materials
  10.  * provided with the distribution, and (3) all advertising materials mentioning
  11.  * features or use of this software display the following acknowledgement:
  12.  * ``This product includes software developed by the University of California,
  13.  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14.  * the University nor the names of its contributors may be used to endorse
  15.  * or promote products derived from this software without specific prior
  16.  * written permission.
  17.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Header: savefile.h,v 1.10 90/12/17 13:48:58 mccanne Exp $
  22.  *
  23.  * Header for offline storage info.
  24.  * Extraction/creation by Jeffrey Mogul, DECWRL.
  25.  *
  26.  * Used to save the received packet headers, after filtering, to
  27.  * a file, and then read them later.
  28.  */
  29.  
  30. /*
  31.  * Each packet in the dump file is prepended with this generic header.
  32.  * This gets around the problem of different headers for different
  33.  * packet interfaces.
  34.  */
  35. struct packet_header {
  36.     struct timeval ts;    /* time stamp */
  37.     u_long len;        /* length this packet (off wire) */
  38.     u_long caplen;        /* length of portion present */
  39. };
  40.  
  41. /* true if the contents of the savefile being read are byte-swapped */
  42. extern int sf_swapped;
  43.  
  44. /* macros for when sf_swapped is true: */
  45. /*
  46.  * We use the "receiver-makes-right" approach to byte order,
  47.  * because time is at a premium when we are writing the file.
  48.  * In other words, the file_header and packet_header records
  49.  * are written in host byte order.
  50.  * Note that the packets are always written in network byte order.
  51.  *
  52.  * ntoh[ls] aren't sufficient because we might need to swap on a big-endian
  53.  * machine (if the file was written in little-end order).
  54.  */
  55. #define    SWAPLONG(y) \
  56. ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
  57. #define    SWAPSHORT(y) \
  58.     ( (((y)&0xff)<<8) | (((y)&0xff00)>>8) )
  59.  
  60.  
  61. extern FILE *sf_readfile;    /* dump file being read from */
  62. extern FILE *sf_writefile;    /* dump file being written to */
  63.  
  64. int sf_read_init();
  65. int sf_read();
  66. int sf_next_packet();
  67. void sf_write_init();
  68. void sf_write();
  69. void sf_err();
  70.  
  71. #define SFERR_TRUNC        1
  72. #define SFERR_BADVERSION    2
  73. #define SFERR_BADF        3
  74. #define SFERR_EOF        4 /* not really an error, just a status */
  75.  
  76.